// $Id: NetDiagram.cs 127 2007-05-29 18:31:17Z xavex2k $

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.Serialization;
using Diagram;
using Diagram.Commands;
using Diagram.Tools;
using Diagram.View;
using PetriDiagram.Model;
using PetriDiagram.Tools;

namespace PetriDiagram
{
    [Serializable]
    public class NetDiagram : Diagram.View.Diagram
    {
        public NetDiagram( PetriNetModel model, ShapeFactory shapeFactory, Size diagramSize )
            : base( model, shapeFactory, diagramSize )
        {
            Init( model );
        }

        private void Init( PetriNetModel model )
        {
            SelectionTool st = new SelectionTool( model, this );
            ConnectionTool ct = new PetriNetConnectionTool( model, this, new PetriNetRelation( model ) );
            ConnectionTool inhibitor = new InhibitorTool( model, this, new InhibitorArc( model ) );
            InsertionTool transitionTool = new InsertionTool( model, this, new Transition( model ) );
            InsertionTool placeTool = new InsertionTool( model, this, new Place( model ) );
            AddTokenTool addTokeTool = new AddTokenTool( model, this );
            RemoveTokenTool removeTokenTool = new RemoveTokenTool( model, this );
            FireTransitionTool fireTransitionTool = new FireTransitionTool( model, this );


            transitionTool.Name = "Insert transition";
            placeTool.Name = "Insert place";

            AddTool( st );
            AddTool( transitionTool );
            AddTool( placeTool );
            AddTool( ct );
            AddTool( inhibitor );
            AddTool( addTokeTool );
            AddTool( removeTokenTool );
            AddTool( fireTransitionTool );

            CurrentTool = st;


            CommandManager<Shape>.Instance.RegisterCommand( new DeleteShapeWithEntityCommand() );
            CommandManager<Shape>.Instance.RegisterCommand( new BringToFrontCommand() );
            CommandManager<Shape>.Instance.RegisterCommand( new SendToBackCommand() );
        }
    }
}
